package com.gopay.common.trace;

import com.gopay.common.trace.enums.TraceType;

/**
 * 日志打印model
 * Created by xuHui on 2017/5/12.
 */
public class TraceLog {
    private TraceType traceType;
    private long time;
    private Object message;
    private Throwable exception;


    public static class Builder {
        private TraceType traceType;
        private long time;
        private Object message;
        private Throwable exception;


        public Builder(TraceType traceType) {
            this.traceType = traceType;
        }


        public Builder time(long time) {
            this.time = time;
            return this;
        }

        public Builder message(Object message) {
            this.message = message;
            return this;
        }

        public Builder exception(Throwable exception) {
            this.exception = exception;
            return this;
        }

        public TraceLog build() {

            return new TraceLog(this);

        }
    }

    public TraceLog(Builder builder) {
        this.traceType = builder.traceType;
        this.time = builder.time;
        this.message = builder.message;
        this.exception = builder.exception;
    }


    /***
     * 使用builer 替代
     * @param traceType
     * @param time
     * @param message
     */
    @Deprecated
    public TraceLog(TraceType traceType, long time, Object message) {
        this.traceType = traceType;
        this.time = time;
        this.message = message;
    }

    /***
     * 使用builder 替代
     * @param traceType
     * @param time
     * @param message
     * @param exception
     */
    @Deprecated
    public TraceLog(TraceType traceType, long time, Object message, Throwable exception) {
        this.traceType = traceType;
        this.time = time;
        this.message = message;
        this.exception = exception;
    }

    public TraceType getTraceType() {
        return traceType;
    }

    public void setTraceType(TraceType traceType) {
        this.traceType = traceType;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }

    public Throwable getException() {
        return exception;
    }

    public void setException(Throwable exception) {
        this.exception = exception;
    }
}
